/**
 * @author Nicolas Lusa (lusan@usi.ch)
 */
package ch.usi.inf.pf2.gui.tool;

import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

import ch.usi.inf.pf2.circuit.Input;
import ch.usi.inf.pf2.gui.Model;

public final class InputCreationTool extends Tool {

    public InputCreationTool(final Model model) {
        super(model, "Select this tool and click on the canvas to create an input.", "../icons/input.png", "../icons/inputBg.png");
    }
    
    public void mouseClicked(final MouseEvent ev) {
    	ImageIcon icon = new ImageIcon(getClass().getResource("../icons/input.png"));
    	String inputName = (String)JOptionPane.showInputDialog( null, "Enter a name for the input", "", JOptionPane.QUESTION_MESSAGE, icon, null, null);
    	
        if(inputName != null) {
        	final Input in = new Input(ev.getX(), ev.getY());
            getCircuit().add(in);
            getSelection().clear();
            getSelection().add(in);
            in.setName(inputName);
        }
    }

}